import asyncio
from fastmcp import Client

from fastmcp.client.transports import StreamableHttpTransport


async def main():

    transport1 = StreamableHttpTransport("http://127.0.0.1:8000/echo/mcp/")

    async with Client(transport=transport1) as client:
        print("Connected to echo server")
        tools = await client.list_tools()
        print("Available tools:", [t.name for t in tools])
        res = await client.call_tool("echo", {"message": "Hello, world!"})
        print(res.content[0].text)

    transport2 = StreamableHttpTransport("http://127.0.0.1:8000/math/mcp/")
    async with Client(transport=transport2) as client:
        print("Connected to math server")
        tools = await client.list_tools()
        print("Available tools:", [t.name for t in tools])
        res = await client.call_tool("add_two", {"n": 1})
        print(res.content[0].text)


if __name__ == "__main__":
    asyncio.run(main())
